#xml.instruct! :xml, :version=>"1.0"

@events2= Event.find_by_sql("SELECT e.id,  e.name as eventName, e.winner, e.date_ini, e.date_fin, c.name as categoryName,c.category_type ,a.name as administratorName,a.lastname,a.ci FROM events e, categories c, administrators a WHERE e.category_id=c.id and e.administrator_id")

xml.events do
  @events2.each do |events2|
@compe = Competitor.find(:all, :conditions => [" event_id = ?", events2.id ])
    xml.event do
      xml.name events2.eventName
      xml.categoryName events2.categoryName
      xml.category_type events2.category_type
      xml.date_ini events2.date_ini
      xml.date_fin events2.date_fin
      xml.winner events2.winner
      xml.administratorName events2.administratorName
      xml.lastname events2.lastname
      xml.ci events2.ci
      xml.competitors do

      @compe.each do |compe|
      xml.competitor do
          xml.nameCompetitor  compe.name
          xml.max_amount compe.max_amount
          xml.event_id compe.event_id
        end
      end
     

#     xml.nameCompetitor2 compe.name
#     xml.score compe.score
#     xml.max_amount compe.max_amount
     

     end

    end
   
 end
 
 
  end

